package optDV;

public class optDV {

	public int NUM_OF_NODES = 100;

	int NUM_OF_SENSORS = 20;

	int NUM_OF_DEPS = Math.min(NUM_OF_NODES, NUM_OF_SENSORS);

	LOC[] Network = new LOC[NUM_OF_NODES];

	SEN[] Sensor = new SEN[NUM_OF_SENSORS];

	DEP[] Deployment = new DEP[NUM_OF_DEPS];

	LOC[] Nodes = new LOC[NUM_OF_NODES];

	SEN[] Sensors = new SEN[NUM_OF_SENSORS];

	double Total_Dep_Value = 0;

	public void init(int[] Tmp) {
		// List of all sensors available
		for (int i = 0; i < NUM_OF_SENSORS; i++) {
			Sensors[i] = new SEN("Sensor " + i, 8.4, 1.0, 2, 3, 'B');
		}

		// List of all nodes
		for (int i = 0; i < NUM_OF_NODES; i++) {
			Nodes[i] = new LOC("Location " + i, 4, 7, 6, 'B');
		}

		// List of sensors being deployed
		for (int i = 0; i < NUM_OF_DEPS; i++) {
			Sensor[i] = Sensors[i];
		}

		// List of nodes being deployed on
		for (int i = 0; i < NUM_OF_DEPS; i++) {
			Network[i] = Nodes[Tmp[i]];
		}
	}

	public double getFitness() {
		for (int k = 0; k < NUM_OF_DEPS; k++) {
			if (Network[k].lType == Sensor[k].sType) {
				Deployment[k] = new DEP(Sensor[k], Network[k]);

				if (Deployment[k].dDepValue >= 1)
					Total_Dep_Value = Total_Dep_Value + Deployment[k].dDepValue;
				else
					Total_Dep_Value = Total_Dep_Value
							- (1 - Deployment[k].dDepValue);

			}// if

		}// end of for loop
		return Total_Dep_Value;
	}

	public static void main(String[] args) {
		optDV dep = new optDV();
		int[] test = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
				17, 18, 19, 20 };
		dep.init(test);
		System.out.println("value= " + dep.getFitness());

	}// end of main

} // end of class

